using UnityEngine;
using System.Collections;

[AddComponentMenu("GK/GodVsAliens/Flocking/Rule/gkGodVsAliensSetPlayerAsFlockingGoal")]
[RequireComponent(typeof(gkSphericalFlockingToGoalRule))]
/// \class  gkGodVsAliensSetPlayerAsFlockingGoal
/// \brief 	Set the player position as the floacking goal
public class gkGodVsAliensSetPlayerAsFlockingGoal : MonoBehaviour
{
	/// The Flocking to goal rule
	private gkSphericalFlockingToGoalRule m_rGoalRule;
	
	/// The player
	private GameObject m_rPlayer;
	
	/// \brief  Called just before the first update
	void Start () 
	{
		// Grab the goal rule
		m_rGoalRule = GetComponent<gkSphericalFlockingToGoalRule>();
		
		// Grab the player
		m_rPlayer = GameObject.Find("Player");
	}
		
	/// \brief  Called each frame
	void Update()
	{
		// Update the goal with the player position
		m_rGoalRule.goal = m_rPlayer.transform.position;
	}
}